﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Administrator
{
    public partial class fExceptionMessageBox : Form
    {
        private bool m_Expanded;
        private String m_ExceptionText;
        private TextBox m_exceptText;

        public fExceptionMessageBox()
        {
            InitializeComponent();
        }

        public void Show(IWin32Window parent, String caption, 
                            String messageText, String exceptionText)
        {
            Text = caption;
            tbMessage.Text = messageText + "\r\n\r\n" + cConst.CAP_MESSAGEBOX_PROMPT;
            m_Expanded = false;
            m_ExceptionText = exceptionText;

         
            
            ShowDialog(parent);
        }

        private void bInformation_Click(object sender, EventArgs e)
        {
            if (m_Expanded == false)
            {
               // btInformation.BackgroundImage = new Bitmap(Ty);
                Height += 6 + 115;
                m_Expanded = true;
                int l1 = pbError.Location.X;
                int l = Width - l1 - l1 - 5;//TO DO: Разобраться с расчетом
               
                m_exceptText = new TextBox{Multiline = true, 
                    ReadOnly = true,
                    Location = new Point(pbError.Location.X, btInformation.Location.Y + btInformation.Height + 6),
                    Width = l,
                    Height = 115,
                    BorderStyle = BorderStyle.Fixed3D,
                    Text = m_ExceptionText
                };

                m_exceptText.Parent = this;

            }
            else
            {
                //btInformation.ImageIndex = 0;
                if (m_exceptText != null)
                {
                    m_exceptText.Parent = null;
                    m_exceptText.Dispose();
                    m_exceptText = null;
                }

                Height -= 6 + 115;
                m_Expanded = false;
            }
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
